   <?php
    $id = null;
    if ( !empty($_GET['id'])) {
        $id = $_REQUEST['id'];
    }     
    if ( null==$id ) {
        header("Location: usuarios");
    }
     /*Atualiza*/ 
    if ( !empty($_POST)) {        
        // keep track post values
        $nome = $_POST['nome'];
        $usuario = $_POST['usuario'];

		$salt = '1%1cAu!g+>K53PY}';	
		$senha = $_POST['senha'];
		$senha = md5($senha . $salt);

        $pdo = Database::connect();
        $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $sql = "UPDATE usuarios set nome = ?, usuario = ?, senha = ? WHERE id = ?";
        $q = $pdo->prepare($sql);
        $q->execute(array($nome,$usuario,$senha,$id));
        Database::disconnect();
        echo '
            <script language>
                $(function(){
                    alerta("Usuário atualizado com sucesso!");
                }); 
            </script>
        ';
        echo "<meta HTTP-EQUIV='Refresh' CONTENT='1;URL=usuarios'>";
    }
        //Exibe sem Loop
        $pdo = Database::connect();
        $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        //Seleciona a tabela
        $sql = "SELECT * FROM usuarios where id = ?";
        $q = $pdo->prepare($sql);
        $q->execute(array($id));
        $data = $q->fetch(PDO::FETCH_ASSOC);
        //Variáveis que serão exibidas
        $nome = $data['nome'];
        $usuario = $data['usuario'];
        $senha = $data['senha'];
        Database::disconnect();
        //exibe sem Loop
?>
    <div id="page-wrapper">
        <div class="row">
          <div class="col-lg-12">
            <h1><i class="fa fa-users"></i> <?php echo $ssusuarios ?></h1>
          </div>
        </div><!-- /.row -->
      <!-- Button to trigger modal -->
        
            <div class="table-responsive">  
            <form class="form-horizontal" action="usuarios-edita&id=<?php echo $id?>" method="post">         
              <table class="table table-bordered table-hover tablesorter">
                <thead>
                  <tr class="success">
                    <th colspan="2">
                    	<div style="float:left; padding:13px 0 0 0">
	                        Editar Dados
                        </div>
                        <div style="float:right">
                            <a class="btn btn-large btn-danger" href="javascript:history.back()">
                            <i class="fa fa-arrow-left"></i> Voltar</a>
                            <button type="submit" class="btn btn-large btn-success"><i class="fa fa-floppy-o"></i> Salvar</button>
                        </div>
                    </th>                        
                  </tr>
                </thead>
                <tbody>
                
                  <tr>
                    <td>
						<b>Nome:</b><br />                       
                    </td>
                    <td style="width:85%">
						<input type="text" name="nome" value="<?php echo $nome;?>" class="form-control"/><br />
                    </td>                                       
                  </tr>
                  <tr>
                    <td>
						<b>Usuário:</b><br />                       
                    </td>
                    <td style="width:85%">
						<input type="text" name="usuario" value="<?php echo $usuario;?>" class="form-control"/><br />
                    </td>                                       
                  </tr>
                  <tr>
                    <td>
						<b>Senha:</b><br />                       
                    </td>
                    <td style="width:85%">
						<input type="password" name="senha" value="" placeholder="*******" class="form-control"/><br />
                    </td>                                       
                  </tr>                  <tr>
                    <td style="text-align: center" colspan="2">
                        <a class="btn btn-large btn-danger" href="javascript:history.back()">
                        <i class="fa fa-arrow-left"></i> Voltar</a>           
                        <button type="submit" class="btn btn-large btn-success"><i class="fa fa-floppy-o"></i> Salvar</button>
                    </td>                                       
                  </tr>                           
                </tbody>
              </table> 
              </form>                           
            </div>

      </div><!-- /#page-wrapper -->

    </div><!-- /#wrapper --> 